import { ReactChild, ReactFragment, ReactPortal, useEffect, useState } from 'react';
import { Redirect } from 'umi';
import { message } from 'antd'
//
// export default (props: { children: boolean | ReactChild | ReactFragment | ReactPortal | null | undefined; }) => {
//   // const { isLogin } = useAuth();
//   const isLogin = false
//   if (isLogin) {
//     return <div>{ props.children }</div>;
//   } else {
//     return <Redirect to="/" />;
//   }
// }
import React from 'react';

const MyComponent = (props: { children: boolean | ReactChild | ReactFragment | ReactPortal | null | undefined; }) => {
  // const isLogin = false
  const [isLogin, setIsLogin] = useState(true)
  useEffect(() => {
    setIsLogin(true)
    if (!isLogin) {
      message.warn('请登录')
    }else {
      message.success('登录成功')
    }
  }, []);
  return (
    <div>
      {
        isLogin ? <div>{ props.children }</div> : <Redirect to="/" />
      }
    </div>
  );
};

export default MyComponent;
